{"ast":null,"code":"import { useRef, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport canUseDom from './Dom/canUseDom';\nvar Portal = /*#__PURE__*/forwardRef(function (props, ref) {\n  var didUpdate = props.didUpdate,\n    getContainer = props.getContainer,\n    children = props.children;\n  var parentRef = useRef();\n  var containerRef = useRef();\n  // Ref return nothing, only for wrapper check exist\n  useImperativeHandle(ref, function () {\n    return {};\n  });\n  // Create container in client side with sync to avoid useEffect not get ref\n  var initRef = useRef(false);\n  if (!initRef.current && canUseDom()) {\n    containerRef.current = getContainer();\n    parentRef.current = containerRef.current.parentNode;\n    initRef.current = true;\n  }\n  // [Legacy] Used by `rc-trigger`\n  useEffect(function () {\n    didUpdate === null || didUpdate === void 0 ? void 0 : didUpdate(props);\n  });\n  useEffect(function () {\n    // Restore container to original place\n    // React 18 StrictMode will unmount first and mount back for effect test:\n    // https://reactjs.org/blog/2022/03/29/react-v18.html#new-strict-mode-behaviors\n    if (containerRef.current.parentNode === null && parentRef.current !== null) {\n      parentRef.current.appendChild(containerRef.current);\n    }\n    return function () {\n      var _containerRef$current, _containerRef$current2;\n      // [Legacy] This should not be handle by Portal but parent PortalWrapper instead.\n      // Since some component use `Portal` directly, we have to keep the logic here.\n      (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.parentNode) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.removeChild(containerRef.current);\n    };\n  }, []);\n  return containerRef.current ? /*#__PURE__*/ReactDOM.createPortal(children, containerRef.current) : null;\n});\nexport default Portal;","map":{"version":3,"names":["useRef","useEffect","forwardRef","useImperativeHandle","ReactDOM","canUseDom","Portal","props","ref","didUpdate","getContainer","children","parentRef","containerRef","initRef","current","parentNode","appendChild","_containerRef$current","_containerRef$current2","removeChild","createPortal"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/rc-util/es/Portal.js"],"sourcesContent":["import { useRef, useEffect, forwardRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport canUseDom from './Dom/canUseDom';\nvar Portal = /*#__PURE__*/forwardRef(function (props, ref) {\n  var didUpdate = props.didUpdate,\n    getContainer = props.getContainer,\n    children = props.children;\n  var parentRef = useRef();\n  var containerRef = useRef();\n  // Ref return nothing, only for wrapper check exist\n  useImperativeHandle(ref, function () {\n    return {};\n  });\n  // Create container in client side with sync to avoid useEffect not get ref\n  var initRef = useRef(false);\n  if (!initRef.current && canUseDom()) {\n    containerRef.current = getContainer();\n    parentRef.current = containerRef.current.parentNode;\n    initRef.current = true;\n  }\n  // [Legacy] Used by `rc-trigger`\n  useEffect(function () {\n    didUpdate === null || didUpdate === void 0 ? void 0 : didUpdate(props);\n  });\n  useEffect(function () {\n    // Restore container to original place\n    // React 18 StrictMode will unmount first and mount back for effect test:\n    // https://reactjs.org/blog/2022/03/29/react-v18.html#new-strict-mode-behaviors\n    if (containerRef.current.parentNode === null && parentRef.current !== null) {\n      parentRef.current.appendChild(containerRef.current);\n    }\n    return function () {\n      var _containerRef$current, _containerRef$current2;\n      // [Legacy] This should not be handle by Portal but parent PortalWrapper instead.\n      // Since some component use `Portal` directly, we have to keep the logic here.\n      (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.parentNode) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.removeChild(containerRef.current);\n    };\n  }, []);\n  return containerRef.current ? /*#__PURE__*/ReactDOM.createPortal(children, containerRef.current) : null;\n});\nexport default Portal;"],"mappings":"AAAA,SAASA,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAEC,mBAAmB,QAAQ,OAAO;AAC1E,OAAOC,QAAQ,MAAM,WAAW;AAChC,OAAOC,SAAS,MAAM,iBAAiB;AACvC,IAAIC,MAAM,GAAG,aAAaJ,UAAU,CAAC,UAAUK,KAAK,EAAEC,GAAG,EAAE;EACzD,IAAIC,SAAS,GAAGF,KAAK,CAACE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